<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            width: 200px;
            height: 200px;
        }
        .box a:hover{
            background-color: chartreuse;
        }
        .content{
            display: flex;
            flex-direction: column;
            font-size: 22px;
        }
        .content span:hover{
            background-color: brown;
        }
    </style>
</head>
<body>
    <div class="box">
        <a href="#/chenchen">视频</a>
        <a href="#/erni">直播</a>
    </div>
    <div class="content">

    </div>
</body>
</html>
<script>
    //hash路由
    //思路：用hashchange事件 监听url地址中hash值的变化, 只要hash值发生变化hashchange的回调函数就会执行, 在回调函数内部获取最新的hash值 ( location.hash ) , 使用switch或者if 判断, 根据不同的hash值调用不同的函数, 完成内容的渲染.
    window.onhashchange = function(){
        switch(location.hash){
            case '#/chenchen':chenchen_page();break;
            case '#/erni':erni_page();break;
        }
    }
    //渲染视频的内容
    function chenchen_page(){
        document.querySelector('.content').innerHTML = `
        <span>杨幂在热舞</span>
        <span>迪丽热巴在热舞</span>
        <span>周艳丽在热舞</span>
        <span>潘文甜在热舞</span>`
    }
    //渲染直播的内容
    function erni_page(){
        document.querySelector('.content').innerHTML = `<span>旭旭宝宝开播了</span>
        <span>米儿开直播了</span>
        <span>米娜开直播了</span>
        <span>苏恩开直播了</span>`
    }
</script>